﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SkinSharp;

namespace DataStudio
{
    public partial class Main : Form
    {
        public SkinH_Net skinh;
        public Main()
        {
            skinh = new SkinH_Net();
            skinh.Attach();
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //主窗体要做的耗时操作
            for (int i = 1; i < 30; i++)
            {
                System.Threading.Thread.Sleep(29);
                WaitForm.ShowMessage(i, "载入中...");
            }
            WaitForm.CloseWaitForm();


            Index f = new Index();
            f.MdiParent = this;
            f.FormBorderStyle = FormBorderStyle.None;
            f.Dock = DockStyle.Fill;
            f.Text = "首页";
            f.Show();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            //Loader f = new Loader();
            //f.MdiParent = this;
            //f.TopLevel = false;
            //f.Dock = DockStyle.Fill;
            //f.Show();
        }

        private bool isExist(string ChildTypeName)
        {
            bool b_result = false;
            foreach (Form frm in MdiChildren)
            {
                //if (frm.GetType().Name == ChildTypeName)
                if (frm.Text == ChildTypeName)
                {
                    frm.Activate();
                    b_result = true;
                    break;
                }
            }
            return b_result;
        }

        public void LoadFormMoudel(string name)
        {
            //if (!this.isExist(name))
            //{
            //    Loader f = new Loader();
            //    f.MdiParent = this;
            //    f.Dock = DockStyle.Fill;
            //    f.Text = name;
            //    f.Show();
            //}
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!isExist("login"))
            {
                Form f = new Form();
                f.MdiParent = this;
                f.Dock = DockStyle.Fill;
                f.Text = "login";
                f.FormBorderStyle = FormBorderStyle.None;
                f.Show();
            }
            
        }

        private void edititToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show(this.mdiTabStrip1.Tabs.Count.ToString());
        }

        private void Main_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Dispose();
            Application.Exit();
        }

    }
}
